Carbon


StringWidth

Header: QuickdrawText.h Carbon status: Supported

Returns the length, in pixels, of the specified text string.

SInt16 StringWidth (
    ConstStr255Param s
);
Parameter descriptions
s

A Pascal string containing the text to be measured.

function result

The length, in pixels, of the specified text string.

DISCUSSION

You should not call StringWidth to measure scaled text. Although StringWidth takes into account the graphics port structure settings, it does not accept scaling parameters, and therefore cannot determine the correct text width result for text to be drawn using scaling factor parameters.

If you specify values in the graphics port spExtra or chExtra fields to change the width of space or nonspace characters, StringWidth takes these values into account.

Because this function measures text in the font, style, and size of the current graphics port, you need to call it once for each individual style run in any line of text that contains multiple style runs.

The StringWidth function works with all script systems.

AVAILABILITY

Supported in Carbon. Available in Carbon 1.0.2 and later when running Mac OS 8.1 or later.


© 2000 Apple Computer, Inc. (Last Updated 6/30/2000)